
const HEXS = [
    '0', '1', '2', '3',
    '4', '5', '6', '7',
    '8', '9', 'A', 'B',
    'C', 'D', 'E', 'F',
];

export function toHex2(value: number) {
    const v1 = (value >> 4) & 0x0F;
    const v0 = value & 0x0F;
    return `${HEXS[v1]}${HEXS[v0]}`;
}

export function toHex4(value: number) {
    const s1 = toHex2((value >> 8) & 0xFF);
    const s0 = toHex2(value & 0xFF);
    return `${s1}${s0}`;
}

export function toHex8(value: number) {
    const s1 = toHex4((value >> 16) & 0xFFFF);
    const s0 = toHex4(value & 0xFFFF);
    return `${s1}${s0}`;
}


